package com.lobo.blog.controller;

import com.lobo.blog.entity.Blog;
import com.lobo.blog.service.BlogService;
import com.lobo.blog.service.TagService;
import com.lobo.blog.service.TypeService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.annotation.Resource;

/**
 * @authoer:MacieSerenity
 * @createDate: 2022/10/15
 * @description:
 */
@Controller
public class BlogController {

    @Resource
    BlogService blogService;

    @RequestMapping(value = "/blog", method = RequestMethod.GET)
    public String toBlog() {
        return "blog";
    }

    @RequestMapping(value = "/blog/{id}", method = RequestMethod.GET)
    public String toBlogInfo(@PathVariable("id") Integer id,
                             Model model) {
        Blog blogAndConvertoHtml = blogService.getBlogAndConvertoHtml(id);
        model.addAttribute("blog",blogAndConvertoHtml);
        return "blog";
    }
}
